import { GetProductTitleOptions } from '@/lib/postme';
import { request } from './request';

// 生成产品标题
export interface GenerateProductTitleResult {
  status: number;
  data: string;
  error: '';
}
export async function generateProductTitle<T = GenerateProductTitleResult>(
  getProductTitleOptions: GetProductTitleOptions,
) {
  let content = '';
  content += `产品的名称：${getProductTitleOptions.name}。\n`;
  content += `产品的优势：${getProductTitleOptions.advantage.join('\n')}。\n`;
  content += `关键词：${getProductTitleOptions.keyWord}。\n`;
  content += `下面是对内容输出的要求：\n`;
  content += `写作的语气：专业的。\n`;
  content += `写作的语言：英语`;
  return request<T, T>({
    url: 'https://www.postme.cn/chatgpt/api/article',
    method: 'POST',
    headers: {},
    data: {
      system:
        'You are a good Amazon seller. Please write the product title for me based on the following information. The title must contain keywords.',
      content: content,
      auth: '123456',
    },
  });
}
